package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ToolsSampleResultsDao;
import com.sugon.entity.ToolsSampleResultsEntity;
import com.sugon.service.ToolsSampleResultsService;
import com.sugon.utils.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * 抽查结果Service实现类
 *
 * @author sugon
 * @date 2019-08-14 08:25:51
 */
@Service("toolsSampleResultsService")
public class ToolsSampleResultsServiceImpl implements ToolsSampleResultsService {
    @Autowired
    private ToolsSampleResultsDao toolsSampleResultsDao;

    @Override
    public ToolsSampleResultsEntity queryObject(String id) {
        return toolsSampleResultsDao.queryObject(id);
    }

    @Override
    public List<ToolsSampleResultsEntity> queryList(Map<String, Object> map) {
        return toolsSampleResultsDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return toolsSampleResultsDao.queryTotal(map);
    }

    @Override
    public int save(ToolsSampleResultsEntity toolsSampleResults) {
        toolsSampleResults.setId(RandomUtil.randomString(32));
        toolsSampleResults.setCreateTime(new Date());
        toolsSampleResults.setCreateUser(getUserId());
        toolsSampleResults.setDelFlag(Integer.valueOf(Constant.IS_NOT_DEL));
        toolsSampleResults.setSampleTime(new Date());
        toolsSampleResults.setSampleUser(getUserId());
        return toolsSampleResultsDao.save(toolsSampleResults);
    }

    @Override
    public int update(ToolsSampleResultsEntity toolsSampleResults) {
        toolsSampleResults.setUpdateTime(new Date());
        toolsSampleResults.setUpdateUser(getUserId());
        return toolsSampleResultsDao.update(toolsSampleResults);
    }

    @Override
    public int delete(String id) {
        return toolsSampleResultsDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return toolsSampleResultsDao.deleteBatch(ids);
    }
}
